<style lang="css">
  .message {
    position: fixed;
    bottom: 50px;
    left: 50%;
    z-index: 999999 !important;
  }
  .message-main {
    margin-left: -50%;
    max-width: 500px;
    background-color: #545454;
    padding: 10px 10px 10px 36px;
    border-radius: 5px;
    color: #fff;
  }
  .message-main.padding-ring {
    padding-right: 36px;
  }
  .message-main .iconfont {
    float: left;
    width: 12px;
    height: 12px;
    line-height: 12px;
    margin-top: 4px;
    background-color: #fff;
    border-radius: 50%;
    margin-left: -27px;
  }
  .message-main .icon-jinggao-copy{
    color:#E80F0F
  }
  .message-main .icon-chenggong{
    color:#09BB07
  }
  .message-main .close {
    float: right;
    margin-right: -27px;
    color: #d8d8d8;
    cursor: pointer;
    margin-top: -1px;
  }
  .slide-fade-enter-active {
    transition: all .3s ease;
  }
  .slide-fade-leave-active {
    transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
  }
  .slide-fade-enter, .slide-fade-leave-to {
    transform: translateY(50px);
    opacity: 0;
  }
  @media screen  and (min-width: 900px) {
    .message-main {
      font-size: 20px;
      padding-left: 40px;
    }
    .message-main .iconfont {
      width: 20px;
      height: 20px;
      line-height: 20px;
      margin-top: 4px;
      margin-left: -30px;
      font-size: 22px;
    }
  }
  @media screen  and (min-width: 1200px) {
    .message-main {
      font-size: 24px;
      padding: 15px 15px 15px  46px;
      line-height: 30px;
    }
    .message-main .iconfont {
      width: 24px;
      height: 24px;
      line-height: 24px;
      margin-top: 2px;
      margin-left: -35px;
      font-size: 26px;
    }
  }
</style>
<template>
  <transition name="slide-fade">
    <div class="message" v-if="show">
      <div :class="['message-main',{'padding-ring':close_btn}]">
        <span :class="['iconfont',type=='success'?'icon-chenggong':'icon-jinggao-copy']"></span>
        <span v-show="close_btn" class="close" @click="show = false">&times;</span>
        <p>{{message}}</p>
      </div>
    </div>
  </transition>
</template>

<script>
  export default {
    name: 'v-message',
    mounted(){
      this.StartTime();
    },
    data(){
      return {
        type:'success',
        message: '123',
        show: false,
        timer: null,
        time:3000,
        close_btn:true
      }
    },
    methods:{
      StartTime(){
        this.show = true;
        if(this.timer){
          clearTimeout(this.timer)
        }else{
          this.timer = setTimeout(()=>{
              this.show = false
          }, this.time);
        }
      }
    }
  }
</script>
